﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

namespace ZHDJ.MobileInterface.html
{
    public partial class ChartView : System.Web.UI.Page
    {
        #region 参数属性
        /// <summary>
        /// BranchID
        /// </summary>
        public string BranchID
        {
            get
            {
                return Microsoft.Security.Application.AntiXss.HtmlEncode(Request.QueryString["BranchID"]);
            }
        }

        /// <summary>
        /// Category
        /// </summary>
        public string Category
        {
            get
            {
                return Microsoft.Security.Application.AntiXss.HtmlEncode(Request.QueryString["Category"]);
            }
        }

        /// <summary>
        /// Chart
        /// </summary>
        public string Chart
        {
            get
            {
                return Microsoft.Security.Application.AntiXss.HtmlEncode(Request.QueryString["Chart"]);
            }
        }

        /// <summary>
        /// H
        /// </summary>
        public int H
        {
            get
            {
                try
                {
                    return Convert.ToInt16(Microsoft.Security.Application.AntiXss.HtmlEncode(Request.QueryString["H"]));
                }
                catch
                {
                    return 250;
                }
            }
        }

        /// <summary>
        /// W
        /// </summary>
        public int W
        {
            get
            {
                try
                {
                    return Convert.ToInt16(Microsoft.Security.Application.AntiXss.HtmlEncode(Request.QueryString["W"]));
                }
                catch
                {
                    return 350;
                }
            }
        } 
        #endregion

        protected void Page_Load(object sender, EventArgs e)
        {
            if (!string.IsNullOrEmpty(this.BranchID))
            {
                DataSet ds = InterfaceHelper.QueryMemberStructureAnalyse(this.BranchID, this.Category);

                this.Chart1.Visible = false;
                this.Chart2.Visible = false;
                this.Chart3.Visible = false;
                this.Chart4.Visible = false;

                this.Chart1.Width = new Unit(this.W);
                this.Chart1.Height = new Unit(this.H);
                this.Chart2.Width = new Unit(this.W);
                this.Chart2.Height = new Unit(this.H);
                this.Chart3.Width = new Unit(this.W);
                this.Chart3.Height = new Unit(this.H);
                this.Chart4.Width = new Unit(this.W);
                this.Chart4.Height = new Unit(this.H);

                if (this.Chart.IndexOf("1") >= 0)
                {
                    this.Chart1.Visible = true;
                    this.Chart1.Series[0]["PieDrawingStyle"] = "SoftEdge";
                    this.Chart1.Series[0].Points.DataBind(ds.Tables[0].Rows, "BranchType", "Counts", "LegendText=BranchType,YValues=Counts,ToolTip=BranchType");
                }
                if (this.Chart.IndexOf("2") >= 0)
                {
                    this.Chart2.Visible = true;
                    this.Chart2.Series[0]["PieDrawingStyle"] = "SoftEdge";
                    this.Chart2.Series[0].Points.DataBind(ds.Tables[1].Rows, "Gender", "Counts", "LegendText=Gender,YValues=Counts,ToolTip=Gender");
                }

                if (this.Chart.IndexOf("3") >= 0)
                {
                    this.Chart3.Visible = true;
                    this.Chart3.Series[0]["PieDrawingStyle"] = "SoftEdge";
                    this.Chart3.Series[0].Points.DataBind(ds.Tables[2].Rows, "YearAge", "Counts", "LegendText=YearAge,YValues=Counts,ToolTip=YearAge");
                }
                if (this.Chart.IndexOf("4") >= 0)
                {
                    this.Chart4.Visible = true;
                    this.Chart4.Series[0]["PieDrawingStyle"] = "SoftEdge";
                    this.Chart4.Series[0].Points.DataBind(ds.Tables[3].Rows, "Educational", "Counts", "LegendText=Educational,YValues=Counts,ToolTip=Educational");
                }
            }
        }
    }
}